import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'
export const constantRoutes = [{
		path: '/redirect',
		component: Layout,
		hidden: true,
	},
	{
		path: '/login',
		component: () =>
			import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/auth-redirect',
		component: () =>
			import('@/views/login/auth-redirect'),
		hidden: true
	},
	{
		path: '/4`04',
		component: () =>
			import('@/views/error-page/404'),
		hidden: true
	},
	{
		path: '/401',
		component: () =>
			import('@/views/error-page/401'),
		hidden: true
	},
	{
		path: '/',
		component: Layout,
		redirect: '/dashboard',
		children: [{
				path: 'dashboard',
				component: () =>
					import('@/views/dashboard/index'),
				name: '首页',
				meta: {
					title: '首页',
					icon: 'el-icon-s-home',
					affix: true
				}
			},
		]
	},
]

export const asyncRoutes = [{
	path: '*',
	redirect: '/404',
	hidden: true
}]

const createRouter = () => new Router({
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router
